#include <Def.h>
#include <qdebug.h>
#include "AddonManagerPrivate.h"
#include "widget/AddonPanel.h"

AddonManager* AddonManager::instance()
{
	static AddonManager mgr;
	return &mgr;
}

AddonManager::AddonManager():
d_ptr(new AddonManagerPrivate(this))
{
}

void AddonManager::initial()
{
	qDebug() << "AddonManagerPrivate init";
	addPackageFromDir("..\\plugins");
}

void AddonManager::destroy()
{
}

bool AddonManager::addPackageFromFile(const QString& file)
{
	auto package = d_ptr->createPackageFromFile(file);
	if(!package)
		return false;

	addPackage(package);
	return true;
}

bool AddonManager::addPackageFromDir(const QString& dir)
{
	return d_ptr->addPackageFromDir(dir);
}

AddonPackage* AddonManager::createPackage(const ModuleInfo& info)
{
	return d_ptr->createPackage(info);
}

void AddonManager::addPackage(AddonPackage* package)
{
	return d_ptr->addPackage(package);
}

QStringList AddonManager::getPackageNameList()const
{
	return d_ptr->getPackageNameList();
}

AddonPackage* AddonManager::getPackageByName(const QString& name)
{
	return d_ptr->getPackageByName(name);
}

bool AddonManager::process(const QMouseEvent& event)
{
	return d_ptr->process(event);
}

bool AddonManager::process(const QKeyEvent& event)
{
	return d_ptr->process(event);
}

bool AddonManager::process(const QWheelEvent& event)
{
	return d_ptr->process(event);
}

/*
void AddonManager::receivedMessage(const AddonMessage& message)
{
	return d_ptr->receivedMessage(message);
}

void AddonManager::sendMessage(const AddonMessage& message)
{
	d_ptr->sendMessage(message);
}*/
